﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;

namespace IYASAKATools
{
    public class ParaInfo
    {

        public ParaInfo()
        {
            ZJ_HAND_SUM_ALL_JUDGE = 0;
            BREAK_FORCE_ALL = 0;
            ZJ_BREAK_FORCE_ALL_SUM = 0;
            ZJ_BREAK_FORCE_ALL_SUM_STD = 60;
            ZJ_HAND_SUM_ALL_STD = 20;
            ZJ_BREAK_FORCE_ALL_SUM_JUDGE = 0;
        }

        /// <summary>
        /// //转向轴类型代号
        /// </summary>
        public int ZXZLXDH { get; set; }

        /// <summary>
        /// //检验类别代号   
        /// </summary>
        public int JYLBDH { get; set; }

        /// <summary>
        /// 总轴数
        /// </summary>
        public int ZZS { get; set; }

        ////制动率标准 
        //QZZDLVBZ HZZDLVBZ
        public float[] ZDLVBZ { get; set; }

        //QZBPHLVBZ  HZBPHLVBZDY60 
        public float[] BPHLVBZDY60 { get; set; }//不平衡率标准（制动率大于等于60%） 

        //HZBPHLVBZXY60
        public float[] BPHLVBZXY60 { get; set; }//不平衡率标准（制动率小于60%    ）

        //QZBPHLVBZ_1 HZBPHLVBZDY60_1
        public float[] BPHLVBZDY60_1 { get; set; }//不平衡率标准（制动率大于等于60% 1级）

        //HZBPHLVBZXY60_1
        public float[] BPHLVBZXY60_1 { get; set; }//不平衡率标准（制动率小于60%    1级） 

        //char strDB_ZZ[6][20]={"YZZZ","EZZZ","SZZZ","SIZZZ","WZZZ","LZZZ"};
        public int[] ZJ_AXIS_WEIGHT { get; set; }      //轮重 

        //char strDB_ZLZ[6][20]={"YZZLZ","EZZLZ","SZZLZ","SIZZLZ","WZZLZ","LZZLZ"};
        public int[] ZJ_AXIS_WEIGHT_L { get; set; }     //左轮重 

        //char strDB_YLZ[6][20]={"YZYLZ","EZYLZ","SZYLZ","SIZYLZ","WZYLZ","LZYLZ"};
        public int[] ZJ_AXIS_WEIGHT_R { get; set; }    //右轮重  

        //复合台轮重
        //char strDB_FHTZLZ[6][20]={"FHTYZZLZ","FHTEZZLZ","FHTSZZLZ","FHTSIZZLZ","FHTWZZLZ","FHTLZZLZ"};
        public int[] ZJ_AXIS_WEIGHT_FHT { get; set; }         //轮重

        //char strDB_FHTYLZ[6][20]={"FHTYZYLZ","FHTEZYLZ","FHTSZYLZ","FHTSIZYLZ","FHTWZYLZ","FHTLZYLZ"};
        public int[] ZJ_AXIS_WEIGHT_FHT_L { get; set; }   //左轮重  

        //char strDB_FHTZZ[6][20]={"FHTYZZZ","FHTEZZZ","FHTSZZZ","FHTSIZZZ","FHTWZZZ","FHTLZZZ"};
        public int[] ZJ_AXIS_WEIGHT_FHT_R { get; set; }   //右轮重

        //ZCZLZ
        public int ZJ_AXIS_WEIGHT_ALL_L { get; set; }   //左轮重和
        //ZCYLZ
        public int ZJ_AXIS_WEIGHT_ALL_R { get; set; }   //右轮重和
        //ZCZZ
        public int ZJ_AXIS_WEIGHT_ALL { get; set; }     //轮重和

        //制动力
        public int[] BREAK_FORCE { get; set; }

        //char strDB_ZZDL[6][20]={"YZZZDZDL","EZZZDZDL","SZZZDZDL","SIZZZDZDL","WZZZDZDL","LZZZDZDL"};
        public int[] BREAK_FORCE_L { get; set; }  //左制动力 

        //char strDB_YZDL[6][20]={"YZYZDZDL","EZYZDZDL","SZYZDZDL","SIZYZDZDL","WZYZDZDL","LZYZDZDL"};
        public int[] BREAK_FORCE_R { get; set; }   //右制动力 

        //过程差
        public float[] DIFFERENCE_FORCE { get; set; }

        //char strDB_ZGCC[6][20]={"YZZZDCZD","EZZZDCZD","SZZZDCZD","SIZZZDCZD","WZZZDCZD","LZZZDCZD"};
        public float[] DIFFERENCE_FORCE_L { get; set; }   //左过程差 

        //char strDB_YGCC[6][20]={"YZYZDCZD","EZYZDCZD","SZYZDCZD","SIZYZDCZD","WZYZDCZD","LZYZDCZD"};
        public float[] DIFFERENCE_FORCE_R { get; set; }   //右过程差 

        //和比
        //char strDB_ZDL[6][20]={"YZZDLV","EZZDLV","SZZDLV","SIZZDLV","WZZDLV","LZZDLV"};
        public float[] ZJ_BREAK_SUM { get; set; }

        //char strDB_ZDLBZ[6][20]={"YZZDLVBZ","EZZDLVBZ","SZZDLVBZ","SIZZDLVBZ","WZZDLVBZ","LZZDLVBZ"};
        public float[] ZJ_BREAK_SUM_STD { get; set; }     //和比标准

        //char strDB_ZDLPD[6][20]={"YZZDLV_PD","EZZDLV_PD","SZZDLV_PD","SIZZDLV_PD","WZZDLV_PD","LZZDLV_PD"}; 
        public int[] ZJ_BREAK_SUM_JUDGE { get; set; }     //和比判定

        //差比
        //char strDB_BPHL[6][20]={"YZBPHLV","EZBPHLV","SZBPHLV","SIZBPHLV","WZBPHLV","LZBPHLV"};
        public float[] ZJ_BREAK_DIF { get; set; }

        public float[] ZJ_BREAK_DIF_STD_DY60 { get; set; }   //大于等于60%标准
        public float[] ZJ_BREAK_DIF_STD_XY60 { get; set; }  //小于60%标准
        public float[] ZJ_BREAK_DIF_STD_DY60_1 { get; set; }   //大于等于60%标准(1级)
        public float[] ZJ_BREAK_DIF_STD_XY60_1 { get; set; }   //小于60%标准(1级)

        //char strDB_BPHLBZ[6][20]={"YZBPHLVBZ","EZBPHLVBZ","SZBPHLVBZ","SIZBPHLVBZ","WZBPHLVBZ","LZBPHLVBZ"};
        public float[] ZJ_BREAK_DIF_STD { get; set; }         //保存数据库用

        //char strDB_BPHLPD[6][20]={"YZBPHLV_PD","EZBPHLV_PD","SZBPHLV_PD","SIZBPHLV_PD","WZBPHLV_PD","LZBPHLV_PD"};
        public int[] ZJ_BREAK_DIF_JUDGE { get; set; }     //差比判定

        //阻滞力
        //char strDB_ZZZL[6][20]={"YZZZZL","EZZZZL","SZZZZL","SIZZZZL","WZZZZL","LZZZZL"};
        public int[] ZJ_BLOCK_FORCE_L { get; set; }   //阻滞力左 -

        //char strDB_YZZL[6][20]={"YZYZZL","EZYZZL","SZYZZL","SIZYZZL","WZYZZL","LZYZZL"};
        public int[] ZJ_BLOCK_FORCE_R { get; set; }   //阻滞力右 -

        //阻滞率
        //char strDB_ZZZLV[6][20]={"YZZZZLV","EZZZZLV","SZZZZLV","SIZZZZLV","WZZZZLV","LZZZZLV"};
        public float[] ZJ_BLOCK_SUM_L { get; set; }   //阻滞率左

        //char strDB_YZZLV[6][20]={"YZYZZLV","EZYZZLV","SZYZZLV","SIZYZZLV","WZYZZLV","LZYZZLV"};
        public float[] ZJ_BLOCK_SUM_R { get; set; }   //阻滞率右

        //char strDB_ZZLBZ[6][20]={"YZZZLVXZBZ","EZZZLVXZBZ","SZZZLVXZBZ","SIZZZLVXZBZ","WZZZLVXZBZ","LZZZLVXZBZ"};
        public float ZJ_BLOCK_SUM_STD { get; set; } //阻滞率标准   -

        //char strDB_ZZZLVPD[6][20]={"YZZZZL_PD","EZZZZL_PD","SZZZZL_PD","SIZZZZL_PD","WZZZZL_PD","LZZZZL_PD"};
        public int[] ZJ_BLOCK_SUM_L_JUDGE { get; set; }  //阻滞率判定

        //char strDB_YZZLVPD[6][20]={"YZYZZL_PD","EZYZZL_PD","SZYZZL_PD","SIZYZZL_PD","WZYZZL_PD","LZYZZL_PD"};
        public int[] ZJ_BLOCK_SUM_R_JUDGE { get; set; }  //阻滞率判定

        //手制动力
        //char strDB_SZDL[6][20]={"YZSZDL","EZSZDL","SZSZDL","SIZSZDL","WZSZDL","LZSZDL"};
        public int[] HAND_FORCE { get; set; }

        //char strDB_ZSZDL[6][20]={"YZZSZDL","EZZSZDL","SZZSZDL","SIZZSZDL","WZZSZDL","LZZSZDL"};
        public int[] HAND_FORCE_L { get; set; }    //左轮手制动力  -

        //char strDB_YSZDL[6][20]={"YZYSZDL","EZYSZDL","SZYSZDL","SIZYSZDL","WZYSZDL","LZYSZDL"};
        public int[] HAND_FORCE_R { get; set; }     //右轮手制动力  -

        //ZSZDL
        public int HAND_FORCE_ALL { get; set; }  //手制动力和

        //ZCSZDLV
        public float ZJ_HAND_SUM_ALL { get; set; }//手制动率

        //SZDLVBZ
        public float ZJ_HAND_SUM_ALL_STD { get; set; }//手制动标准  -

        //SZDLV_PD
        public int ZJ_HAND_SUM_ALL_JUDGE { get; set;} //手制动判定

        //ZCZDL
        public int BREAK_FORCE_ALL{get;set;}            //整车制动力

        //ZCZDLV
        public float ZJ_BREAK_FORCE_ALL_SUM {get;set;}     //整车制动率

        //ZCZDLVBZ
        public float ZJ_BREAK_FORCE_ALL_SUM_STD {get;set;}    //整车制动标准  -

        //ZCZDLV_PD
        public int ZJ_BREAK_FORCE_ALL_SUM_JUDGE { get; set; } //整车制动判定

        //项目判定
        //char strDB_ZDPD[6][20]={"YZZDZ_PD","EZZDZ_PD","SZZDZ_PD","SIZZDZ_PD","WZZDZ_PD","LZZDZ_PD"};
        public int[] ZJ_ITEM_JUDGE { get; set; }

        public int[] AXIS_TYPE { get; set; }   //0是前轴  1是后轴 
    }

    public class CalClass
    {
        public void ComputingResult_ZJ(ParaInfo info)
        {
            try
            {
                if (info.ZXZLXDH == 0)   //单
                {
                    info.AXIS_TYPE[0] = 0;
                }
                else                    //双
                {
                    info.AXIS_TYPE[0] = 0;
                    info.AXIS_TYPE[1] = 0;
                }

                for (int i = 0; i < info.ZZS; i++)
                {
                    //info.ZJ_BREAK_SUM_STD[i] = info.ZDLVBZ[info.AXIS_TYPE[i]];
                    info.ZJ_BREAK_DIF_STD_DY60[i] = info.BPHLVBZDY60[info.AXIS_TYPE[i]];
                    info.ZJ_BREAK_DIF_STD_XY60[i] = info.BPHLVBZXY60[info.AXIS_TYPE[i]];

                    //1级标准
                    info.ZJ_BREAK_DIF_STD_DY60_1[i] = info.BPHLVBZDY60_1[info.AXIS_TYPE[i]];
                    info.ZJ_BREAK_DIF_STD_XY60_1[i] = info.BPHLVBZXY60_1[info.AXIS_TYPE[i]];
                }


                for (int index = 0; index < info.ZZS; index++)
                {
                    info.ZJ_AXIS_WEIGHT_ALL += info.ZJ_AXIS_WEIGHT[index];
                    info.ZJ_AXIS_WEIGHT_ALL_L += info.ZJ_AXIS_WEIGHT_L[index];
                    info.ZJ_AXIS_WEIGHT_ALL_R += info.ZJ_AXIS_WEIGHT_R[index];

                    //手制动
                    info.HAND_FORCE[index] = info.HAND_FORCE_L[index] + info.HAND_FORCE_R[index];
                    info.HAND_FORCE_ALL += info.HAND_FORCE[index];
                    //轴重
                    info.ZJ_AXIS_WEIGHT[index] = info.ZJ_AXIS_WEIGHT_L[index] + info.ZJ_AXIS_WEIGHT_R[index];
                    //复合台轴重
                    info.ZJ_AXIS_WEIGHT_FHT[index] = info.ZJ_AXIS_WEIGHT_FHT_L[index] + info.ZJ_AXIS_WEIGHT_FHT_R[index];
                    //制动力
                    info.BREAK_FORCE[index] = info.BREAK_FORCE_L[index] + info.BREAK_FORCE_R[index];
                    info.BREAK_FORCE_ALL += info.BREAK_FORCE[index];
                    //过程差
                    info.DIFFERENCE_FORCE[index] = Math.Abs((info.DIFFERENCE_FORCE_L[index] - info.DIFFERENCE_FORCE_R[index]));
                    //
                    ////////////////////////////////和比////////////////////////////////////////
                    //对于多轴及并装轴车辆，静态轴和取复合台轴重。
                    int ZZ = info.ZJ_AXIS_WEIGHT[index];
                    if (info.ZZS > 2)
                    {
                        ZZ = info.ZJ_AXIS_WEIGHT_FHT[index];
                    }


                    if (ZZ != 0)
                    {
                        info.ZJ_BREAK_SUM[index] = (float)((float)(info.BREAK_FORCE[index]) / (float)ZZ * 100.0);
                    }

                    else
                    {
                        info.ZJ_BREAK_SUM[index] = 0;
                    }

                    info.ZJ_BREAK_SUM[index] = float.Parse(Math.Round((double)info.ZJ_BREAK_SUM[index], 1).ToString("f1"));   //处理成一位小数

                    if (info.ZJ_BREAK_SUM[index] >= info.ZJ_BREAK_SUM_STD[index])
                    {
                        info.ZJ_BREAK_SUM_JUDGE[index] = 1;
                    }
                    else
                    {
                        info.ZJ_BREAK_SUM_JUDGE[index] = 2;
                    }



                    ///////////////////////////////////////差比/////////////////////////////////////////////////////

                    if (info.AXIS_TYPE[index] != 0 && info.ZJ_BREAK_SUM[index] < 60)  //后轴开始 制动率小于60%
                    {
                        //综检对于多轴及并装轴车辆，静态轴和取复合台轴重。
                        ZZ = info.ZJ_AXIS_WEIGHT[index];
                        if (info.ZZS > 2)
                        {
                            ZZ = info.ZJ_AXIS_WEIGHT_FHT[index];
                        }

                        if (ZZ != 0)
                        {
                            info.ZJ_BREAK_DIF[index] = (float)((float)(info.DIFFERENCE_FORCE[index]) / (float)(ZZ) * 100.0);
                        }
                        else
                        {
                            info.ZJ_BREAK_DIF[index] = 0;
                        }


                        info.ZJ_BREAK_DIF[index] = float.Parse(Math.Round((double)info.ZJ_BREAK_DIF[index], 1).ToString("f1"));   //处理成一位小数

                        info.ZJ_BREAK_DIF_STD[index] = info.ZJ_BREAK_DIF_STD_XY60[index];
                        if (info.ZJ_BREAK_DIF[index] <= info.ZJ_BREAK_DIF_STD_XY60[index])
                        {
                            info.ZJ_BREAK_DIF_JUDGE[index] = 1;
                            if (info.JYLBDH == 12)   //检验类别代号
                            {
                                if (info.ZJ_BREAK_DIF[index] <= info.ZJ_BREAK_DIF_STD_XY60_1[index])
                                {
                                    info.ZJ_BREAK_DIF_STD[index] = info.ZJ_BREAK_DIF_STD_XY60_1[index];
                                    info.ZJ_BREAK_DIF_JUDGE[index] = 10;
                                }
                                else
                                {
                                    info.ZJ_BREAK_DIF_JUDGE[index] = 11;
                                }
                            }
                        }
                        else
                        {
                            info.ZJ_BREAK_DIF_JUDGE[index] = 2;
                        }
                    }
                    else
                    {
                        int m_MaxForce = info.BREAK_FORCE_L[index];
                        if (m_MaxForce < info.BREAK_FORCE_R[index])
                            m_MaxForce = info.BREAK_FORCE_R[index];

                        if (m_MaxForce != 0)
                            info.ZJ_BREAK_DIF[index] = (float)((float)(info.DIFFERENCE_FORCE[index]) / (float)(m_MaxForce) * 100.0);
                        else
                            info.ZJ_BREAK_DIF[index] = 0;

                        info.ZJ_BREAK_DIF[index] = float.Parse(Math.Round((double)info.ZJ_BREAK_DIF[index], 1).ToString("f1"));   //处理成一位小数

                        info.ZJ_BREAK_DIF_STD[index] = info.ZJ_BREAK_DIF_STD_DY60[index];
                        if (info.ZJ_BREAK_DIF[index] <= info.ZJ_BREAK_DIF_STD_DY60[index])
                        {
                            info.ZJ_BREAK_DIF_JUDGE[index] = 1;
                            if (info.ZJ_BREAK_DIF[index] <= info.ZJ_BREAK_DIF_STD_DY60_1[index])
                            {
                                info.ZJ_BREAK_DIF_STD[index] = info.ZJ_BREAK_DIF_STD_DY60_1[index];
                                info.ZJ_BREAK_DIF_JUDGE[index] = 10;
                            }
                            else
                            {
                                info.ZJ_BREAK_DIF_JUDGE[index] = 11;
                            }
                        }
                        else
                            info.ZJ_BREAK_DIF_JUDGE[index] = 2;
                    }

                    ///////////////////////////////////////阻滞比/////////////////////////////////////////////

                    if (info.ZJ_AXIS_WEIGHT[index] != 0)
                    {
                        info.ZJ_BLOCK_SUM_L[index] = (float)((float)(info.ZJ_BLOCK_FORCE_L[index]) / (float)(info.ZJ_AXIS_WEIGHT[index]) * 100.0);
                        info.ZJ_BLOCK_SUM_R[index] = (float)((float)(info.ZJ_BLOCK_FORCE_R[index]) / (float)(info.ZJ_AXIS_WEIGHT[index]) * 100.0);
                    }
                    else
                    {
                        info.ZJ_BLOCK_SUM_L[index] = 0;
                        info.ZJ_BLOCK_SUM_R[index] = 0;
                    }

                    info.ZJ_BLOCK_SUM_L[index] = float.Parse(Math.Round((double)info.ZJ_BLOCK_SUM_L[index], 1).ToString("f1"));   //处理成一位小数
                    info.ZJ_BLOCK_SUM_R[index] = float.Parse(Math.Round((double)info.ZJ_BLOCK_SUM_R[index], 1).ToString("f1"));   //处理成一位小数

                    if (info.ZJ_BLOCK_SUM_STD > 0)   //判定阻滞比
                    {
                        if (info.ZJ_BLOCK_SUM_L[index] <= info.ZJ_BLOCK_SUM_STD)
                            info.ZJ_BLOCK_SUM_L_JUDGE[index] = 1;
                        else
                            info.ZJ_BLOCK_SUM_L_JUDGE[index] = 2;

                        if (info.ZJ_BLOCK_SUM_R[index] <= info.ZJ_BLOCK_SUM_STD)
                            info.ZJ_BLOCK_SUM_R_JUDGE[index] = 1;
                        else
                            info.ZJ_BLOCK_SUM_R_JUDGE[index] = 2;
                    }
                    else
                    {
                        info.ZJ_BLOCK_SUM_L_JUDGE[index] = 3;
                        info.ZJ_BLOCK_SUM_R_JUDGE[index] = 3;
                    }

                    if (info.ZJ_BREAK_SUM_JUDGE[index] == 2 || info.ZJ_BREAK_DIF_JUDGE[index] == 2 || info.ZJ_BLOCK_SUM_L_JUDGE[index] == 2 || info.ZJ_BLOCK_SUM_R_JUDGE[index] == 2)
                        info.ZJ_ITEM_JUDGE[index] = 2;
                    else
                        info.ZJ_ITEM_JUDGE[index] = 1;
                }

                if (info.ZJ_AXIS_WEIGHT_ALL > 0)
                {
                    //手制动
                    info.ZJ_HAND_SUM_ALL = (float)((float)(info.HAND_FORCE_ALL) / (float)(info.ZJ_AXIS_WEIGHT_ALL) * 100.0);
                    info.ZJ_HAND_SUM_ALL = float.Parse(Math.Round((double)info.ZJ_HAND_SUM_ALL, 1).ToString("f1"));   //处理成一位小数

                    if (info.ZJ_HAND_SUM_ALL >= info.ZJ_HAND_SUM_ALL_STD)
                        info.ZJ_HAND_SUM_ALL_JUDGE = 1;
                    else
                        info.ZJ_HAND_SUM_ALL_JUDGE = 2;

                    ////////////////////////////////整车制动比///////////////////////////////////////////
                    info.ZJ_BREAK_FORCE_ALL_SUM = (float)((float)(info.BREAK_FORCE_ALL) / (float)(info.ZJ_AXIS_WEIGHT_ALL) * 100.0);
                    info.ZJ_BREAK_FORCE_ALL_SUM = float.Parse(Math.Round((double)info.ZJ_BREAK_FORCE_ALL_SUM, 1).ToString("f1"));   //处理成一位小数

                    if (info.ZJ_BREAK_FORCE_ALL_SUM >= info.ZJ_BREAK_FORCE_ALL_SUM_STD)
                        info.ZJ_BREAK_FORCE_ALL_SUM_JUDGE = 1;
                    else
                        info.ZJ_BREAK_FORCE_ALL_SUM_JUDGE = 2;
                }
            }
            catch (Exception ex)
            { 
            
            }
        }

        public void GetLampZJResult(RESULT_LAMP_ZJ lampZJ)
        {
            try
            {
                #region 左外灯
                if (string.IsNullOrEmpty(lampZJ.ZWDYGGQ) == false && lampZJ.ZWDYGGQ != "-")
                {
                    if (Convert.ToInt32(lampZJ.ZWDYGGQ) < Convert.ToInt32(lampZJ.DGGQXZ))
                    {
                        lampZJ.ZWDYGGQ_PD = "2";
                    }
                    else
                    {
                        lampZJ.ZWDYGGQ_PD = "1";
                    }
                }

                if (string.IsNullOrEmpty(lampZJ.ZWDJGCZPY) == false && lampZJ.ZWDJGCZPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.ZWDJGCZPY) < Convert.ToDouble(lampZJ.JGCZPYXZSX) && Convert.ToDouble(lampZJ.ZWDJGCZPY) > Convert.ToDouble(lampZJ.JGCZPYXZXX))
                    {
                        lampZJ.ZWDJGCZPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.ZWDJGCZPY_PD = "2";
                    }

                    lampZJ.ZWDJGCZPYL = GetLampCZPYL(Convert.ToDouble(lampZJ.ZWDJGCZPY), Convert.ToDouble(lampZJ.ZWDJGDG)).ToString("F0");
                }

                if (string.IsNullOrEmpty(lampZJ.ZWDJGSPPY) == false && lampZJ.ZWDJGSPPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.ZWDJGSPPY) > Convert.ToDouble("-" + lampZJ.JGZDZPXZ) && Convert.ToDouble(lampZJ.ZWDJGSPPY) < Convert.ToDouble(lampZJ.JGZDYPXZ))
                    {
                        lampZJ.ZWDJGSPPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.ZWDJGSPPY_PD = "2";
                    }
                }

                if (string.IsNullOrEmpty(lampZJ.ZWDYGCZPY) == false && lampZJ.ZWDYGCZPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.ZWDYGCZPY) < Convert.ToDouble(lampZJ.YGCZPYXZSX) && Convert.ToDouble(lampZJ.ZWDYGCZPY) > Convert.ToDouble(lampZJ.YGCZPYXZXX))
                    {
                        lampZJ.ZWDYGCZPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.ZWDYGCZPY_PD = "2";
                    }

                    lampZJ.ZWDYGCZPYL = GetLampCZPYL(Convert.ToDouble(lampZJ.ZWDYGCZPY), Convert.ToDouble(lampZJ.ZWDYGDG)).ToString();
                }

                if (string.IsNullOrEmpty(lampZJ.ZWDYGSPPY) == false && lampZJ.ZWDYGSPPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.ZWDYGSPPY) > Convert.ToDouble("-" + lampZJ.YGZDZPXZ) && Convert.ToDouble(lampZJ.ZWDYGSPPY) < Convert.ToDouble(lampZJ.YGZDYPXZ))
                    {
                        lampZJ.ZWDYGSPPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.ZWDYGSPPY_PD = "2";
                    }
                }
                #endregion

                #region 右外灯
                if (string.IsNullOrEmpty(lampZJ.YWDYGGQ) == false && lampZJ.YWDYGGQ != "-")
                {
                    if (Convert.ToInt32(lampZJ.YWDYGGQ) < Convert.ToInt32(lampZJ.DGGQXZ))
                    {
                        lampZJ.YWDYGGQ_PD = "2";
                    }
                    else
                    {
                        lampZJ.YWDYGGQ_PD = "1";
                    }
                }

                if (string.IsNullOrEmpty(lampZJ.YWDJGCZPY) == false && lampZJ.YWDJGCZPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.YWDJGCZPY) < Convert.ToDouble(lampZJ.JGCZPYXZSX) && Convert.ToDouble(lampZJ.YWDJGCZPY) > Convert.ToDouble(lampZJ.JGCZPYXZXX))
                    {
                        lampZJ.YWDJGCZPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.YWDJGCZPY_PD = "2";
                    }

                    lampZJ.YWDJGCZPYL = GetLampCZPYL(Convert.ToDouble(lampZJ.YWDJGCZPY), Convert.ToDouble(lampZJ.YWDJGDG)).ToString("F0");
                }

                if (string.IsNullOrEmpty(lampZJ.YWDJGSPPY) == false && lampZJ.YWDJGSPPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.YWDJGSPPY) > Convert.ToDouble("-" + lampZJ.JGZDZPXZ) && Convert.ToDouble(lampZJ.YWDJGSPPY) < Convert.ToDouble(lampZJ.JGZDYPXZ))
                    {
                        lampZJ.YWDJGSPPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.YWDJGSPPY_PD = "2";
                    }
                }

                if (string.IsNullOrEmpty(lampZJ.YWDYGCZPY) == false && lampZJ.YWDYGCZPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.YWDYGCZPY) < Convert.ToDouble(lampZJ.YGCZPYXZSX) && Convert.ToDouble(lampZJ.YWDYGCZPY) > Convert.ToDouble(lampZJ.YGCZPYXZXX))
                    {
                        lampZJ.YWDYGCZPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.YWDYGCZPY_PD = "2";
                    }

                    lampZJ.YWDYGCZPYL = GetLampCZPYL(Convert.ToDouble(lampZJ.YWDYGCZPY), Convert.ToDouble(lampZJ.YWDYGDG)).ToString("F0");
                }

                if (string.IsNullOrEmpty(lampZJ.YWDYGSPPY) == false && lampZJ.YWDYGSPPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.YWDYGSPPY) > Convert.ToDouble("-"+lampZJ.YGZDZPXZ) && Convert.ToDouble(lampZJ.YWDYGSPPY) < Convert.ToDouble(lampZJ.YGZDYPXZ))
                    {
                        lampZJ.YWDYGSPPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.YWDYGSPPY_PD = "2";
                    }
                }
                #endregion

                #region 左内灯
                if (string.IsNullOrEmpty(lampZJ.ZNDYGGQ) == false && lampZJ.ZNDYGGQ != "-")
                {
                    if (Convert.ToInt32(lampZJ.ZNDYGGQ) < Convert.ToInt32(lampZJ.DGGQXZ))
                    {
                        lampZJ.ZNDYGGQ_PD = "2";
                    }
                    else
                    {
                        lampZJ.ZNDYGGQ_PD = "1";
                    }
                }

                if (string.IsNullOrEmpty(lampZJ.ZNDJGCZPY) == false && lampZJ.ZNDJGCZPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.ZNDJGCZPY) < Convert.ToDouble(lampZJ.JGCZPYXZSX) && Convert.ToDouble(lampZJ.ZNDJGCZPY) > Convert.ToDouble(lampZJ.JGCZPYXZXX))
                    {
                        lampZJ.ZNDJGCZPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.ZNDJGCZPY_PD = "2";
                    }

                    lampZJ.ZNDJGCZPYL = GetLampCZPYL(Convert.ToDouble(lampZJ.ZNDJGCZPY), Convert.ToDouble(lampZJ.ZNDJGDG)).ToString("F0");
                }

                if (string.IsNullOrEmpty(lampZJ.ZNDJGSPPY) == false && lampZJ.ZNDJGSPPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.ZNDJGSPPY) > Convert.ToDouble("-" + lampZJ.JGZDZPXZ) && Convert.ToDouble(lampZJ.ZNDJGSPPY) < Convert.ToDouble(lampZJ.JGZDYPXZ))
                    {
                        lampZJ.ZNDJGSPPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.ZNDJGSPPY_PD = "2";
                    }
                }

                if (string.IsNullOrEmpty(lampZJ.ZNDYGCZPY) == false && lampZJ.ZNDYGCZPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.ZNDYGCZPY) < Convert.ToDouble(lampZJ.YGCZPYXZSX) && Convert.ToDouble(lampZJ.ZNDYGCZPY) > Convert.ToDouble(lampZJ.YGCZPYXZXX))
                    {
                        lampZJ.ZNDYGCZPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.ZNDYGCZPY_PD = "2";
                    }

                    lampZJ.ZNDYGCZPYL = GetLampCZPYL(Convert.ToDouble(lampZJ.ZNDYGCZPY), Convert.ToDouble(lampZJ.ZNDYGDG)).ToString("F0");
                }

                if (string.IsNullOrEmpty(lampZJ.ZNDYGSPPY) == false && lampZJ.ZNDYGSPPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.ZNDYGSPPY) > Convert.ToDouble("-"+lampZJ.YGZDZPXZ) && Convert.ToDouble(lampZJ.ZNDYGSPPY) < Convert.ToDouble(lampZJ.YGZDYPXZ))
                    {
                        lampZJ.ZNDYGSPPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.ZNDYGSPPY_PD = "2";
                    }
                }
                #endregion

                #region 右内灯
                if (string.IsNullOrEmpty(lampZJ.YNDYGGQ) == false && lampZJ.YNDYGGQ != "-")
                {
                    if (Convert.ToInt32(lampZJ.YNDYGGQ) < Convert.ToInt32(lampZJ.DGGQXZ))
                    {
                        lampZJ.YNDYGGQ_PD = "2";
                    }
                    else
                    {
                        lampZJ.YNDYGGQ_PD = "1";
                    }
                }

                if (string.IsNullOrEmpty(lampZJ.YNDJGCZPY) == false && lampZJ.YNDJGCZPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.YNDJGCZPY) < Convert.ToDouble(lampZJ.JGCZPYXZSX) && Convert.ToDouble(lampZJ.YNDJGCZPY) > Convert.ToDouble(lampZJ.JGCZPYXZXX))
                    {
                        lampZJ.YNDJGCZPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.YNDJGCZPY_PD = "2";
                    }

                    lampZJ.YNDJGCZPYL = GetLampCZPYL(Convert.ToDouble(lampZJ.YNDJGCZPY), Convert.ToDouble(lampZJ.YNDJGDG)).ToString("F0");
                }

                if (string.IsNullOrEmpty(lampZJ.YNDJGSPPY) == false && lampZJ.YNDJGSPPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.YNDJGSPPY) > Convert.ToDouble("-" + lampZJ.JGZDZPXZ) && Convert.ToDouble(lampZJ.YNDJGSPPY) < Convert.ToDouble(lampZJ.JGZDYPXZ))
                    {
                        lampZJ.YNDJGSPPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.YNDJGSPPY_PD = "2";
                    }
                }

                if (string.IsNullOrEmpty(lampZJ.YNDYGCZPY) == false && lampZJ.YNDYGCZPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.YNDYGCZPY) < Convert.ToDouble(lampZJ.YGCZPYXZSX) && Convert.ToDouble(lampZJ.YNDYGCZPY) > Convert.ToDouble(lampZJ.YGCZPYXZXX))
                    {
                        lampZJ.YNDYGCZPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.YNDYGCZPY_PD = "2";
                    }

                    lampZJ.YNDYGCZPYL = GetLampCZPYL(Convert.ToDouble(lampZJ.YNDYGCZPY), Convert.ToDouble(lampZJ.YNDYGDG)).ToString("F0");
                }

                if (string.IsNullOrEmpty(lampZJ.YNDYGSPPY) == false && lampZJ.YNDYGSPPY != "-")
                {
                    if (Convert.ToDouble(lampZJ.YNDYGSPPY) > Convert.ToDouble("-"+lampZJ.YGZDZPXZ) && Convert.ToDouble(lampZJ.YNDYGSPPY) < Convert.ToDouble(lampZJ.YGZDYPXZ))
                    {
                        lampZJ.YNDYGSPPY_PD = "1";
                    }
                    else
                    {
                        lampZJ.YNDYGSPPY_PD = "2";
                    }
                }
                #endregion
            }
            catch(Exception ex){}
        }
        //双怠速
        public void GetSDSZJResult(RESULT_SDS SDSZJ)
        {
            try
            {
                if (string.IsNullOrEmpty(SDSZJ.GDSCO) == false && SDSZJ.GDSCO != "-")
                {
                    if (Convert.ToDouble(SDSZJ.GDSCO) > Convert.ToDouble(SDSZJ.GDSCOXZ))
                    {
                        SDSZJ.GDSCO_PD = "2";
                    }
                    else
                    {
                        SDSZJ.GDSCO_PD = "1";
                    }
                }
                if (string.IsNullOrEmpty(SDSZJ.GDSHC) == false && SDSZJ.GDSHC != "-")
                {
                    if (Convert.ToDouble(SDSZJ.GDSHC) > Convert.ToDouble(SDSZJ.GDSHCXZ))
                    {
                        SDSZJ.GDSHC_PD = "2";
                    }
                    else
                    {
                        SDSZJ.GDSHC_PD = "1";
                    }
                }
                if (string.IsNullOrEmpty(SDSZJ.GLKQXS) == false && SDSZJ.GLKQXS != "-")
                {
                    if (Convert.ToDouble(SDSZJ.GLKQXS) < Convert.ToDouble(SDSZJ.GLKQXSXX) || Convert.ToDouble(SDSZJ.GLKQXS) > Convert.ToDouble(SDSZJ.GLKQXSSX))
                    {
                        SDSZJ.GDSHC_PD = "2";
                    }
                    else
                    {
                        SDSZJ.GDSHC_PD = "1";
                    }
                }
                if (string.IsNullOrEmpty(SDSZJ.DSCO) == false && SDSZJ.DSCO != "-")
                {
                    if (Convert.ToDouble(SDSZJ.DSCO) > Convert.ToDouble(SDSZJ.DSCOXZ))
                    {
                        SDSZJ.GDSHC_PD = "2";
                    }
                    else
                    {
                        SDSZJ.GDSHC_PD = "1";
                    }
                }
                if (string.IsNullOrEmpty(SDSZJ.DSHC) == false && SDSZJ.DSHC != "-")
                {
                    if (Convert.ToDouble(SDSZJ.DSHC) > Convert.ToDouble(SDSZJ.DSHCXZ))
                    {
                        SDSZJ.GDSHC_PD = "2";
                    }
                    else
                    {
                        SDSZJ.GDSHC_PD = "1";
                    }
                }

            }
            catch (Exception ex) { }

        
        }
        //稳态工况
        public void GetASMZJResult(RESULT_ASM ASMZJ)
        {
            try {

                if (string.IsNullOrEmpty(ASMZJ.CO5025JG) == false && ASMZJ.CO5025JG != "-")
                {
                    if (Convert.ToDouble(ASMZJ.CO5025JG) > Convert.ToDouble(ASMZJ.CO5025XZ))
                    {
                        ASMZJ.CO5025_PD = "2";
                    }
                    else
                    {
                        ASMZJ.CO5025_PD = "1";
                    }
                }

                if (string.IsNullOrEmpty(ASMZJ.HC5025JG) == false && ASMZJ.HC5025JG != "-")
                {
                    if (Convert.ToDouble(ASMZJ.HC5025JG) > Convert.ToDouble(ASMZJ.HC5025XZ))
                    {
                        ASMZJ.HC5025_PD = "2";
                    }
                    else
                    {
                        ASMZJ.HC5025_PD = "1";
                    }
                }
                if (string.IsNullOrEmpty(ASMZJ.NO5025JG) == false && ASMZJ.NO5025JG != "-")
                {
                    if (Convert.ToDouble(ASMZJ.NO5025JG) > Convert.ToDouble(ASMZJ.NO5025XZ))
                    {
                        ASMZJ.NO5025_PD = "2";
                    }
                    else
                    {
                        ASMZJ.NO5025_PD = "1";
                    }
                }
                if (string.IsNullOrEmpty(ASMZJ.CO2540JG) == false && ASMZJ.CO2540JG != "-")
                {
                    if (Convert.ToDouble(ASMZJ.CO2540JG) > Convert.ToDouble(ASMZJ.CO2540XZ))
                    {
                        ASMZJ.CO2540_PD = "2";
                    }
                    else
                    {
                        ASMZJ.CO2540_PD = "1";
                    }
                }
                if (string.IsNullOrEmpty(ASMZJ.HC2540JG) == false && ASMZJ.HC2540JG != "-")
                {
                    if (Convert.ToDouble(ASMZJ.HC2540JG) > Convert.ToDouble(ASMZJ.HC2540XZ))
                    {
                        ASMZJ.HC2540_PD = "2";
                    }
                    else
                    {
                        ASMZJ.HC2540_PD = "1";
                    }
                }
                if (string.IsNullOrEmpty(ASMZJ.NO2540JG) == false && ASMZJ.NO2540JG != "-")
                {
                    if (Convert.ToDouble(ASMZJ.NO2540JG) > Convert.ToDouble(ASMZJ.NO2540XZ))
                    {
                        ASMZJ.NO2540_PD = "2";
                    }
                    else
                    {
                        ASMZJ.NO2540_PD = "1";
                    }
                }
     
            }

            catch (Exception ex) { }
        
        }
        //瞬态工况
        public void GetVMASZJResult(RESULT_VMAS VMASZJ)
        {
            try
            {
                if (string.IsNullOrEmpty(VMASZJ.COJG) == false && VMASZJ.COJG != "-")
                {
                    if (Convert.ToDouble(VMASZJ.COJG) > Convert.ToDouble(VMASZJ.COXZ))
                    {
                        VMASZJ.CO_PD = "2";
                    }
                    else
                    {
                        VMASZJ.CO_PD = "1";
                    }
                }
                if (string.IsNullOrEmpty(VMASZJ.HCJG) == false && VMASZJ.HCJG != "-")
                {
                    if (Convert.ToDouble(VMASZJ.HCJG) > Convert.ToDouble(VMASZJ.HCXZ))
                    {
                        VMASZJ.HC_PD = "2";
                    }
                    else
                    {
                        VMASZJ.HC_PD = "1";
                    }
                }
                if (string.IsNullOrEmpty(VMASZJ.NOJG) == false && VMASZJ.NOJG != "-")
                {
                    if (Convert.ToDouble(VMASZJ.NOJG) > Convert.ToDouble(VMASZJ.NOXZ))
                    {
                        VMASZJ.NO_PD = "2";
                    }
                    else
                    {
                        VMASZJ.NO_PD = "1";
                    }
                }
                if (string.IsNullOrEmpty(VMASZJ.HC_NOJG) == false && VMASZJ.HC_NOJG != "-")
                {
                    if (Convert.ToDouble(VMASZJ.HC_NOJG) > Convert.ToDouble(VMASZJ.HC_NOXZ))
                    {
                        VMASZJ.HC_NO_PD = "2";
                    }
                    else
                    {
                        VMASZJ.HC_NO_PD = "1";
                    }
                }




            }

            catch (Exception ex) { }
        
        }
        //加载减速
        public void GetJZJSZJResult(RESULT_LD JZJSZJ) 
        {
            try
            {
                if (string.IsNullOrEmpty(JZJSZJ.GXSXS80) == false && JZJSZJ.GXSXS80 != "-" && string.IsNullOrEmpty(JZJSZJ.GXSXS90) == false && JZJSZJ.GXSXS90 != "-" && string.IsNullOrEmpty(JZJSZJ.GXSXS100) == false && JZJSZJ.GXSXS100 != "-")
                {
                    if (Convert.ToDouble(JZJSZJ.GXSXS80) > Convert.ToDouble(JZJSZJ.GXSXSXZ) || Convert.ToDouble(JZJSZJ.GXSXS90) > Convert.ToDouble(JZJSZJ.GXSXSXZ) || Convert.ToDouble(JZJSZJ.GXSXS100) > Convert.ToDouble(JZJSZJ.GXSXSXZ))
                    {
                        JZJSZJ.GXSXS_PD = "2";
                    }
                    else
                    {
                        JZJSZJ.GXSXS_PD = "1";
                    }
                }
                if (string.IsNullOrEmpty(JZJSZJ.GLJG) == false && JZJSZJ.GLJG != "-")
                {
                    if (Convert.ToDouble(JZJSZJ.GLJG) < Convert.ToDouble(JZJSZJ.GLXZ))
                    {
                        JZJSZJ.GL_PD = "2";
                    }
                    else
                    {
                        JZJSZJ.GL_PD = "1";
                    }
                }





            }
            catch (Exception ex) { }
        
        }
        private double GetLampCZPYL(double fH, double fDG)
        {
            double UD = (fH - 1) * fDG;
            return UD;
        }

        private float GetCZPYL(float UD, float fDG)
        {
            float  fH= UD / fDG + 1;
            return fH;
        }
    }
}
